package cn.inbot.shopadmin.module.mine.view;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;

import com.alibaba.android.arouter.facade.annotation.Route;

import org.jetbrains.annotations.Nullable;

import cn.inbot.shopadmin.R;
import cn.inbot.shopadmin.app.RouterUrls;
import cn.inbot.lib.framework.PBApplication;
import cn.inbot.lib.framework.annotation.InjectLayout;
import cn.inbot.lib.framework.mvvm.PBActivity;
import cn.inbot.lib.framework.router.PBRouter;

import static cn.inbot.lib.util.ext.ToastExtKt.showToast;

/**
 * Created by shisenkun on 2021/5/11.
 */
@Route(path = RouterUrls.DEMO_REGIST)
@InjectLayout(layoutResId = R.layout.activity_regist)
public class RegistActivity extends PBActivity {

    private Button btnRegist;

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        btnRegist = findViewById(R.id.btnRegist);
        btnRegist.setOnClickListener(v -> showToast("注册"));
    }

    @Override
    protected void onResume() {
        super.onResume();
        setupToolbar(R.id.toolbar, true, true).setTitle("注册");
        getSupportActionBar().setHomeAsUpIndicator(R.mipmap.ic_close);
        immersiveStatusBar(R.color.colorPrimary, true);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_regist, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_item_login: {
                PBRouter.INSTANCE
                        .buildWithDefaultAnim(RouterUrls.DEMO_LOGIN)
                        .withOptionsCompat(ActivityOptionsCompat.makeCustomAnimation(
                                this, R.anim.slide_bottom_in, R.anim.slide_bottom_none))
                        .navigation();
                PBApplication.mainHandler.postDelayed(() -> finish(), 300);
            }
            break;
        }
        return true;
    }

}
